<?php
defined("_VALID_ACCESS") || die('Direct access forbidden');
    class Eyeworx_Inventory_FramesInstall extends ModuleInstall {

        public function install() {
            try {
                $importType = array(
                    'new' => 'Import new product',
                    'old' => 'Import previous product'
                );
                Utils_CommonDataCommon::new_array('Eyeworx/Inventory/Frames/importType', $importType);

                $rim = array(
                    'fullrim'=>'Full Rim',
                    'semi'=>'Semi Rimless',
                    'rimless'=>'Rimless'
                );
                Utils_CommonDataCommon::new_array('Eyeworx/Inventory/Frames/rim', $rim);

                $material = array(
                    'metal' => 'Metal',
                    'plastic' => 'Plastic',
                    'flexible' => 'Flexible Metal',
                    'plasticmetal' => 'Plastic and Metal'
                );
                Utils_CommonDataCommon::new_array('Eyeworx/Inventory/Frames/material', $material);

                $rboframes_recordset = new Eyeworx_Inventory_Frames_RBO_RBOFrames();
                $rboframes_recordset->install();
                $rboframes_recordset->add_default_access();
                $rboframes_recordset->set_caption('Frames');

                $rboframes_recordset = new RBO_RecordsetAccessor('eyeworx_frames');
                $rboframes_recordset->new_addon('Eyeworx/Inventory/Frames','frames_import_addon',array('Eyeworx_Inventory_FramesCommon', 'frames_import_addon_label'));
            } catch (Exception $e) {
                return false;
            }
            return true;
        }

        public function uninstall() {
            try {
                $rboframes_recordset = new Eyeworx_Inventory_Frames_RBO_RBOFrames();
                $rboframes_recordset->uninstall();

                $rboframes_recordset = new RBO_RecordsetAccessor('eyeworx_frames');
                $rboframes_recordset->delete_addon('Eyeworx/Inventory/Frames','frames_import_addon',array('Eyeworx_Inventory_FramesCommon', 'frames_import_addon_label'));

                Utils_CommonDataCommon::remove('Eyeworx/Inventory/Frames');
                Utils_CommonDataCommon::remove('Eyeworx/Inventory/Frames/rim');
                Utils_CommonDataCommon::remove('Eyeworx/Inventory/Frames/material');
            } catch (Exception $e) {
                return false;
            }
            return true;
        }

        public function requires($v) {
            return array(
                array('name'=>'Base/Lang','version'=>0),
                array('name'=>'Utils/RecordBrowser','version'=>0),
            );
        }

        public function info() {
            return array(
                'Author'=>'Velicaria, Maureen D.',
                'Description'=>'List of Frames imported'
            );
        }

        public function version() {
            return array('1.0');
        }

        public function simple_setup() {
            return array('package'=>__('Eyeworx'), 'option'=>__('Frame'));
        }

    }
?>